package com.uml.umlwork.config.security;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.uml.umlwork.entity.User;
import org.springframework.stereotype.Service;

/**
 * 生成token的工厂
 *
 * @author Siki
 * @date 2020/12/21
 */
@Service("TokenFactory")
public class JWTFactory {
    public String getToken(User user) {
        String token="";
        token= JWT.create().withAudience(user.getId())
                .sign(Algorithm.HMAC256(user.getPassword()));
        return token;
    }
}
